<!DOCTYPE html>
<html>

<head>
  <title>Quarkus - Kubernetes Config</title>
  <script id="adobe_dtm" src="https://www.redhat.com/dtm.js" type="text/javascript"></script>
  <script src="/assets/javascript/highlight.pack.js" type="text/javascript"></script>
  <META HTTP-EQUIV='Content-Security-Policy' CONTENT="default-src 'none'; script-src 'self' 'unsafe-eval' 'sha256-ANpuoVzuSex6VhqpYgsG25OHWVA1I+F6aGU04LoI+5s=' 'sha256-ipy9P/3rZZW06mTLAR0EnXvxSNcnfSDPLDuh3kzbB1w=' js.bizographics.com https://www.redhat.com assets.adobedtm.com jsonip.com https://ajax.googleapis.com https://www.googletagmanager.com https://www.google-analytics.com https://use.fontawesome.com; style-src 'self' https://fonts.googleapis.com https://use.fontawesome.com; img-src 'self' *; media-src 'self' ; frame-src https://www.googletagmanager.com https://www.youtube.com; frame-ancestors 'none'; base-uri 'none'; object-src 'none'; form-action 'none'; font-src 'self' https://use.fontawesome.com https://fonts.gstatic.com;">
  <META HTTP-EQUIV='X-Frame-Options' CONTENT="DENY">
  <META HTTP-EQUIV='X-XSS-Protection' CONTENT="1; mode=block">
  <META HTTP-EQUIV='X-Content-Type-Options' CONTENT="nosniff">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Quarkus: Supersonic Subatomic Java">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:site" content="@QuarkusIO"> 
  <meta name="twitter:creator" content="@QuarkusIO">
  <meta property="og:url" content="https://quarkus.io/guides/kubernetes-config" />
  <meta property="og:title" content="Quarkus - Kubernetes Config" />
  <meta property="og:description" content="Quarkus: Supersonic Subatomic Java" />
  <meta property="og:image" content="/assets/images/quarkus_card.png" />
  <link rel="canonical" href="https://quarkus.io/guides/kubernetes-config">
  <link rel="shortcut icon" type="image/png" href="/favicon.ico" >
  <link rel="stylesheet" href="https://quarkus.io/guides/stylesheet/config.css" />
  <link rel="stylesheet" href="/assets/css/main.css" />
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
  <link rel="alternate" type="application/rss+xml"  href="https://quarkus.io/feed.xml" title="Quarkus">
  <script src="https://quarkus.io/assets/javascript/goan.js" type="text/javascript"></script>
  <script src="https://quarkus.io/assets/javascript/hl.js" type="text/javascript"></script>
</head>

<body class="guides">
  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NJWS5L"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

  <div class="nav-wrapper">
  <div class="grid-wrapper">
    <div class="width-12-12">
      <input type="checkbox" id="checkbox" />
      <nav id="main-nav" class="main-nav">
  <div class="container">
    <div class="logo-wrapper">
      
        <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_600px_reverse.png" class="project-logo" title="Quarkus"></a>
      
    </div>
    <label class="nav-toggle" for="checkbox">
      <i class="fa fa-bars"></i>
    </label>
    <div id="menu" class="menu">
      <span>
        <a href="/get-started/" class="">Get Started</a>
      </span>
      <span>
        <a href="/guides/" class="active">Guides</a>
      </span>
      <span>
        <a href="/community/" class="">Community</a>
      </span>
      <span>
        <a href="/support/" class="">Support</a>
      </span>
      <span>
        <a href="/blog/" class="">Blog</a>
      </span>
      <span>
        <a href="https://code.quarkus.io" class="button-cta secondary white">Start Coding</a>
      </span>
    </div>
  </div>
      </nav>
    </div>
  </div>
</div>

  <div class="content">
    <div class="guide">
  <div class="width-12-12">
    <h1 class="text-caps">Quarkus - Kubernetes Config</h1>
    <div class="hide-mobile toc"><ul class="sectlevel1">
<li><a href="#configuration">Configuration</a></li>
<li><a href="#usage">Usage</a>
<ul class="sectlevel2">
<li><a href="#priority-of-obtained-properties">Priority of obtained properties</a></li>
<li><a href="#kubernetes-permissions">Kubernetes Permissions</a></li>
</ul>
</li>
<li><a href="#configuration-reference">Configuration Reference</a></li>
</ul></div>
    <div>
      <div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>Quarkus includes the <code>kubernetes-config</code> extension which allows developers to use Kubernetes <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/configmap">ConfigMaps</a> and <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/secret">Secrets</a> as a configuration source, without having to mount them into the <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod/">Pod</a> running the Quarkus application.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="configuration"><a class="anchor" href="#configuration"></a>Configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Once you have your Quarkus project configured you can add the <code>kubernetes-config</code> extension
by running the following command in your project base directory.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">./mvnw quarkus:add-extension -Dextensions="kubernetes-config"</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will add the following to your <code>pom.xml</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="xml" class="language-xml hljs">&lt;dependency&gt;
    &lt;groupId&gt;io.quarkus&lt;/groupId&gt;
    &lt;artifactId&gt;quarkus-kubernetes-config&lt;/artifactId&gt;
&lt;/dependency&gt;</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="usage"><a class="anchor" href="#usage"></a>Usage</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The extension works by reading ConfigMaps and Secrets directly from the Kubernetes API server using the <a href="kubernetes-client">Kubernetes Client</a>.</p>
</div>
<div class="paragraph">
<p>The extension understands the following types of ConfigMaps and Secrets as input sources:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>ConfigMaps and Secrets that contain literal data (see <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-literal-values">this</a> for an example on how to create one)</p>
</li>
<li>
<p>ConfigMaps and Secrets created from files named <code>application.properties</code>, <code>application.yaml</code> or <code>application.yml</code> (see <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files">this</a> for an example on how to create one).</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>You have to explicitly enable the retrieval of ConfigMaps and Secrets by setting <code>quarkus.kubernetes-config.enabled=true</code>.
The default is <code>false</code> in order to make it easy to test the application locally.</p>
</div>
<div class="paragraph">
<p>Afterwards, set the <code>quarkus.kubernetes-config.configmaps</code> property to configure which ConfigMaps should be used.
Set the <code>quarkus.kubernetes-config.secrets</code> property to configure which Secrets should be used.
To access ConfigMaps and Secrets from a specific namespace, you can set the <code>quarkus.kubernetes-config.namespace</code> property.</p>
</div>
<div class="sect2">
<h3 id="priority-of-obtained-properties"><a class="anchor" href="#priority-of-obtained-properties"></a>Priority of obtained properties</h3>
<div class="paragraph">
<p>The properties obtained from the ConfigMaps and Secrets have a higher priority than (i.e. they override) any properties of the same name that are found in <code>application.properties</code> (or the YAML equivalents), but they have lower priority than properties set via Environment Variables or Java System Properties.</p>
</div>
</div>
<div class="sect2">
<h3 id="kubernetes-permissions"><a class="anchor" href="#kubernetes-permissions"></a>Kubernetes Permissions</h3>
<div class="paragraph">
<p>Since reading ConfigMaps involves interacting with the Kubernetes API Server, when <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/">RBAC</a> is enabled on the cluster, the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/">ServiceAccount</a>
that is used to run the application needs to have the proper permissions for such access.</p>
</div>
<div class="paragraph">
<p>Thankfully, when using the <code>kubernetes-config</code> extension along with the <a href="deploying-to-kubernetes">Kubernetes</a> extension, all the necessary Kubernetes resources to make that happen are automatically generated.</p>
</div>
<div class="sect3">
<h4 id="secrets"><a class="anchor" href="#secrets"></a>Secrets</h4>
<div class="paragraph">
<p>By default, the <a href="deploying-to-kubernetes">Kubernetes</a> extension doesn&#8217;t generate the necessary resources to allow accessing secrets.
Set <code>quarkus.kubernetes-config.secrets.enabled=true</code> to generate the necessary role and corresponding role binding.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="configuration-reference"><a class="anchor" href="#configuration-reference"></a>Configuration Reference</h2>
<div class="sectionbody">
<div class="paragraph configuration-legend">
<p><span class="icon"><i class="fa fa-lock" title="Fixed at build time"></i></span> Configuration property fixed at build time - All other configuration properties are overridable at runtime</p>
</div>
<table class="tableblock frame-all grid-all stretch configuration-reference">
<colgroup>
<col style="width: 80%;">
<col style="width: 10%;">
<col style="width: 10%;">
</colgroup>
<tbody>
<tr>
<th class="tableblock halign-left valign-top"><p class="tableblock"><a id="quarkus-kubernetes-config-kubernetes-config-source-config_configuration"></a><a href="#quarkus-kubernetes-config-kubernetes-config-source-config_configuration">Configuration property</a></p></th>
<th class="tableblock halign-left valign-middle"><p class="tableblock">Type</p></th>
<th class="tableblock halign-left valign-middle"><p class="tableblock">Default</p></th>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.enabled"></a><code><a href="#quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.enabled">quarkus.kubernetes-config.enabled</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>If set to true, the application will attempt to look up the configuration from the API server</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.fail-on-missing-config"></a><code><a href="#quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.fail-on-missing-config">quarkus.kubernetes-config.fail-on-missing-config</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>If set to true, the application will not start if any of the configured config sources cannot be located</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>true</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.config-maps"></a><code><a href="#quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.config-maps">quarkus.kubernetes-config.config-maps</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>ConfigMaps to look for in the namespace that the Kubernetes Client has been configured for</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">list of string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.secrets"></a><code><a href="#quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.secrets">quarkus.kubernetes-config.secrets</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Secrets to look for in the namespace that the Kubernetes Client has been configured for. If you use this, you probably want to enable <code>quarkus.kubernetes-config.secrets.enabled</code>.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">list of string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.namespace"></a><code><a href="#quarkus-kubernetes-config-kubernetes-config-source-config_quarkus.kubernetes-config.namespace">quarkus.kubernetes-config.namespace</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Namespace to look for config maps and secrets. If this is not specified, then the namespace configured in the kubectl config context is used. If the value is specified and the namespace doesn&#8217;t exist, the application will fail to start.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
</tbody>
</table>
</div>
</div>
    </div>
  </div>
</div>

  </div>

  <div class="content project-footer">
  <div class="footer-section">
    <div class="logo-wrapper">
      <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_reverse.svg" class="project-logo" title="Quarkus"></a>
    </div>
  </div>
  <div class="grid-wrapper">
    <p class="grid__item width-3-12">Quarkus is open. All dependencies of this project are available under the <a href='https://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache Software License 2.0</a> or compatible license.<br /><br />This website was built with <a href='https://jekyllrb.com/' target='_blank'>Jekyll</a>, is hosted on <a href='https://pages.github.com/' target='_blank'>Github Pages</a> and is completely open source. If you want to make it better, <a href='https://github.com/quarkusio/quarkusio.github.io' target='_blank'>fork the website</a> and show us what you’ve got.</p>

    
      <div class="width-1-12 project-links">
        <span>Navigation</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="/">Home</a></li>
          
            <li><a href="/guides">Guides</a></li>
          
            <li><a href="/community/#contributing">Contribute</a></li>
          
            <li><a href="/faq">FAQ</a></li>
          
            <li><a href="/get-started">Get Started</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Contribute</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://twitter.com/quarkusio">Follow us</a></li>
          
            <li><a href="https://github.com/quarkusio">GitHub</a></li>
          
            <li><a href="/security">Security&nbsp;policy</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Get Help</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://groups.google.com/forum/#!forum/quarkus-dev">Forums</a></li>
          
            <li><a href="https://quarkusio.zulipchat.com">Chatroom</a></li>
          
        </ul>
      </div>
    

    
      <div class="width-3-12 more-links">
        <span>Quarkus is made of community projects</span>
        <ul class="footer-links">
          
            <li><a href="https://vertx.io/" target="_blank">Eclipse Vert.x</a></li>
          
            <li><a href="https://microprofile.io" target="_blank">Eclipse MicroProfile</a></li>
          
            <li><a href="https://hibernate.org" target="_blank">Hibernate</a></li>
          
            <li><a href="https://netty.io" target="_blank">Netty</a></li>
          
            <li><a href="https://resteasy.github.io" target="_blank">RESTEasy</a></li>
          
            <li><a href="https://camel.apache.org" target="_blank">Apache Camel</a></li>
          
            <li><a href="https://code.quarkus.io/" target="_blank">And many more...</a></li>
          
        </ul>
      </div>
    
  </div>
</div>
  <div class="content redhat-footer">
  <div class="grid-wrapper">
    <span class="licence">
      <i class="fab fa-creative-commons"></i><i class="fab fa-creative-commons-by"></i> <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC by 3.0</a> | <a href="https://www.redhat.com/en/about/privacy-policy">Privacy Policy</a>
    </span>
    <span class="redhat">
      Sponsored by
    </span>
    <span class="redhat-logo">
      <a href="https://www.redhat.com/" target="_blank"><img src="/assets/images/redhat_reversed.svg"></a>
    </span>
  </div>
</div>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" integrity="sha384-8gBf6Y4YYq7Jx97PIqmTwLPin4hxIzQw5aDmUg/DDhul9fFpbbLcLh3nTIIDJKhx" crossorigin="anonymous"></script>
  <script type="text/javascript" src="/assets/javascript/mobile-nav.js"></script>
  <script type="text/javascript" src="/assets/javascript/scroll-down.js"></script>
  <script src="/assets/javascript/satellite.js" type="text/javascript"></script>
  <script src="https://quarkus.io/guides/javascript/config.js" type="text/javascript"></script>
  <script src="/assets/javascript/search-filter.js" type="text/javascript"></script>
  <script src="/assets/javascript/back-to-top.js" type="text/javascript"></script>
</body>

</html>
